package com.hjm.project.salaryPlan.aaoCashbackDetails.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.salaryPlan.aaoCashbackDetails.domain.AaoCashbackDetails;
import com.hjm.project.salaryPlan.aaoCashbackDetails.service.IAaoCashbackDetailsService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import javax.annotation.Resource;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 底薪计划奖励Controller
 * 
 * @author maker-platform
 * @date 2022-04-12
 */
@Controller
@RequestMapping("/salaryPlan/aaoCashbackDetails")
public class AaoCashbackDetailsController extends BaseController {
    private String prefix = "salaryPlan/aaoCashbackDetails";

    @Resource
    private IAaoCashbackDetailsService aaoCashbackDetailsService;

    @RequiresPermissions("salaryPlan:aaoCashbackDetails:view")
    @GetMapping()
    public String aaoCashbackDetails() {
        return prefix + "/aaoCashbackDetails";
    }

    /**
     * 查询底薪计划奖励列表
     */
    @RequiresPermissions("salaryPlan:aaoCashbackDetails:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(AaoCashbackDetails aaoCashbackDetails) {
        startPage();
        List<AaoCashbackDetails> list = aaoCashbackDetailsService.selectAaoCashbackDetailsList(aaoCashbackDetails);
        return getDataTable(list);
    }

    /**
     * 导出底薪计划奖励列表
     */
    @RequiresPermissions("salaryPlan:aaoCashbackDetails:export")
    @Log(title = "底薪计划奖励", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(AaoCashbackDetails aaoCashbackDetails) {
        List<AaoCashbackDetails> list = aaoCashbackDetailsService.selectAaoCashbackDetailsList(aaoCashbackDetails);
        ExcelUtil<AaoCashbackDetails> util = new ExcelUtil<AaoCashbackDetails>(AaoCashbackDetails.class);
        return util.exportExcel(list, "aaoCashbackDetails");
    }

    /**
     * 新增底薪计划奖励
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存底薪计划奖励
     */
    @RequiresPermissions("salaryPlan:aaoCashbackDetails:add")
    @Log(title = "底薪计划奖励", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(AaoCashbackDetails aaoCashbackDetails) {
        return toAjax(aaoCashbackDetailsService.insertAaoCashbackDetails(aaoCashbackDetails));
    }

    /**
     * 修改底薪计划奖励
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Integer id, ModelMap mmap) {
        AaoCashbackDetails aaoCashbackDetails = aaoCashbackDetailsService.selectAaoCashbackDetailsById(id);
        mmap.put("aaoCashbackDetails", aaoCashbackDetails);
        return prefix + "/edit";
    }

    /**
     * 修改保存底薪计划奖励
     */
    @RequiresPermissions("salaryPlan:aaoCashbackDetails:edit")
    @Log(title = "底薪计划奖励", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(AaoCashbackDetails aaoCashbackDetails) {
        return toAjax(aaoCashbackDetailsService.updateAaoCashbackDetails(aaoCashbackDetails));
    }

    /**
     * 删除底薪计划奖励
     */
    @RequiresPermissions("salaryPlan:aaoCashbackDetails:remove")
    @Log(title = "底薪计划奖励", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(aaoCashbackDetailsService.deleteAaoCashbackDetailsByIds(ids));
    }
}
